<template>
  <!--    面包屑导航-->
    <div style="margin-top: 20px;margin-left: 20px">
        <el-breadcrumb separator="/">
            <el-breadcrumb-item ><b>我的课堂</b></el-breadcrumb-item>
            <el-breadcrumb-item>课程信息</el-breadcrumb-item>
        </el-breadcrumb>
    </div>
  <!-- 表格 -->
    <div class="table-container">
        <el-table :data="tableData" stripe style="width: 100%">
            <el-table-column prop="courseNumber" label="课程号"  width="300px"/>
            <el-table-column prop="course" label="课程名"  width="300px"/>
            <el-table-column label="操作">
                <template #default="scope">
                    <el-button
                            type="primary"
                            @click="handleSignIn(scope.row.courseNumber)"

                    >
                        签到<el-icon class="el-icon--right"><ArrowRight /></el-icon>
                    </el-button>
                    <el-button
                            type="primary"
                            @click="handleStudent(scope.row.courseNumber)"
                    >
                        查看课程学生<el-icon class="el-icon--right"><ArrowRight /></el-icon>
                    </el-button>
                    <el-button
                            type="primary"
                            @click="handleLeaveStudent(scope.row.courseNumber)"
                    >
                        查看请假学生<el-icon class="el-icon--right"><ArrowRight /></el-icon>
                    </el-button>
                    <el-button
                            type="primary"
                            @click="handleUpdateCourse(scope.row)"
                    >
                            课程调整<el-icon class="el-icon--right"><ArrowRight /></el-icon>
                    </el-button>

                </template>
            </el-table-column>

        </el-table>
    </div>
</template>


<script setup>
//页面初始化调用函数
import {onMounted, ref} from "vue";
import axios from "axios";
import {ArrowRight} from "@element-plus/icons-vue";
import router from "../../../../router/index.js";
import request8090 from "../../../../utils/request8090.js";
onMounted(()=>{
    course()
})

/*获取课程信息*/
const tableData =ref([])
/*表格数据*/
const course=()=>{
    request8090({
        url:'/teacher/getteachcourses',
        method:'GET',
        params:{teacherNumber:sessionStorage.getItem("teacherNumber")},
    }).then(res=>{
        if (200 == res.data.errorCode){
            tableData.value=res.data.data;
        }
    })
}
// 点击签到按钮时存储课程号并跳转路由
const handleSignIn = (courseNumber) => {
    sessionStorage.setItem("courseNumber", courseNumber);
    router.push('/classStart/teacherPostSign'); // 跳转到签到页面
}
// 查看学生人数按钮时存储课程号并跳转路由
const handleStudent = (courseNumber) => {
    sessionStorage.setItem("courseNumber", courseNumber);
    router.push('/classStart/courseStudentCountsView'); // 跳转到查看学生页面
}
const handleLeaveStudent = (courseNumber) => {
    sessionStorage.setItem("courseNumber", courseNumber);
    router.push('/classStart/courseStudentLeaveView'); // 跳转到查看请假学生页面
}
// 调整课程按钮时存储课程号课程名并跳转路由
const handleUpdateCourse = (row) => {
    sessionStorage.setItem("courseNumber", row.courseNumber);
    sessionStorage.setItem("course",row.course);
    router.push('/classStart/adjustCourseView'); // 跳转到调整课程页面
}


</script>

<style scoped>

</style>